package com.cxg.fairy.util;

import android.content.Context;
import android.graphics.Color;

import com.yanyusong.y_divideritemdecoration.Y_Divider;
import com.yanyusong.y_divideritemdecoration.Y_DividerBuilder;
import com.yanyusong.y_divideritemdecoration.Y_DividerItemDecoration;

/**
 * Created by Administrator on 2018/2/6.
 */

public class MyDividerItemDecoration extends Y_DividerItemDecoration {

    private float rightWidthDp = 1;

    private float bottomWidthDp = 2;

    private float leftWidthDp = 1;

    private int color = Color.parseColor("#EAEAEA");

    public MyDividerItemDecoration(Context context) {
        super(context);
    }

    public MyDividerItemDecoration(Context context, float mRightWidthDp, float mBottomWidthDp, float mLeftWidthDp, int mColor) {
        super(context);
        this.rightWidthDp = mRightWidthDp;
        this.bottomWidthDp = mBottomWidthDp;
        this.leftWidthDp = mLeftWidthDp;
        this.color = mColor;
    }

    @Override
    public Y_Divider getDivider(int itemPosition) {
        Y_Divider divider = null;
        switch (itemPosition % 2) {
            case 0:
                //每一行第一个显示rignt和bottom
                divider = new Y_DividerBuilder()
                        .setRightSideLine(true, color, rightWidthDp, 0, 0)
                        .setBottomSideLine(true, color, bottomWidthDp, 0, 0)
                        .create();
                break;
            case 1:
                //第二个显示Left和bottom
                divider = new Y_DividerBuilder()
                        .setLeftSideLine(true, color, leftWidthDp, 0, 0)
                        .setBottomSideLine(true, color, bottomWidthDp, 0, 0)
                        .create();
                break;
            default:
                break;
        }
        return divider;
    }
}
